Each sound record contains the following fields:
1) Sound id: used for referencing sounds.
2) Sound flags: see header_sounds.py for a list of available flags.
3) Sound file: filename of the sound.
The file module_sounds.py is where the sound effects of the module are getting recorded and defined. As module_music.py the file simply consists of a list of tuples. Sounds are getting used at a huge variety of occassions, like footsteps of troop and horse agents, yelling sounds of human agents and snorts of horses or clashes and releases of weapons, to name just a few of them.
The following sound flags are available for usage:
sf_2d | lets the sound's volume level not be depend anymore on its distance to the camera but be constant. 2d sounds should also only take stereo into account. |
sf_always_send_via_network | forces a sound run on server with the operation agent_play_sound to always be synced to all clients, even if they are more then 20 meters away from this agent (the default limit).[1] |
sf_looping | lets the sound loop. |
sf_priority_x |
determines on a scale from 1 to 15 the priority of this sound. Higher priority sounds tend to overwrite lower ones if all sound channels are currently being used (at the same time). Distance also manipulates the resulting priority:[2]
|
sf_start_at_random_pos | lets the sound start at a random position in the sound file. |
sf_stream_from_hd | lets this sound be streamed from harddisk. Recommended for large sound files that are not played often. |
sf_use_next_for_far | WFaS sound flag. Up4research if working in Native as well. |
sf_vol_x | determines on a scale from 1 to 15 the volume of a sound, the higher the value the higher the level of volume. |
Most of the knowledge about this topic is based on many tests of xenoargh who was afterwards fairly confident that he has pinpointed the problem of seemingly random lockups that would halt the game state, and found a solution. It turned out that problem isn't graphics at all; HERR_BUFFER_LOCK errors were a symptom of CPU lock states happening, not the result of running out of VRAM. The real lockup issue appears to be sounds, in particular, the sound format. He converted all of the OGG files (including all of the Taleworlds sounds) to 16-bit 22kHz mono WAV and the HERR_BUFFER_LOCK errors disappeared.[3] Alternatively it is adviced to ensure that the sound files are mono, 44.100 khz and with 16-bit PCM.[4]
As for music tracks you can in theory use OGG and WAV (and MP3) files for the sound effects.[5] Warband is however known to have problems with sounds. The sound engine used is performing much better with WAV files. If you have only OGG files, these will perform worse and crash the engine sooner or later. All short files should be WAV! Using WAV files might increase the overall filesize of the DLC but in the end you are going to profit from it.[6]
It is a common misconception that OGG files are smaller but they are only smaller on disk. As soon as the game engine starts up it will unpack all these OGG files and put them into memory. Your 6kb large OGG files will become 10mb.[6] Warband just reuses the reference decompressor libraries which are free. However, they use them probably inefficiently, because the game engine is the one having to implement the streaming part with the generic tools and FMOD (which is the middleware they use). Storing sounds as WAV might seem pretty wasteful, albeit sounds and music are still a small part of the mod package. However, if the CPU is bottlenecked in Warband due to all the stuff going on and the game engine doesn't use extra threads/CPU cores for decoding/uncompressing Vorbis/MP3 sound, then it makes sense that doing that extra processing every frame adds some overhead which the WAV format doesn't have. This is just educated guessing.[7]
Contrary, large sound files that are not played often should be streamed from harddisk. This will mean they are not loaded into memory at the startup and will not strain the memory so much. These sound files should be in OGG to not get in trouble with harddisk slowness. Use the sound flag sf_stream_from_hd at the respective entries in your module_sounds.py.[6]
Open question about upper limit at sounds, Caba`drin, Modding Q&A, answered here, MadVader, Modding Q&A
Different death sounds, Somebody, Modding Q&A
sf_priority, MadVader, Modding Q&A
Sounds info bits, Caba`drin, Modding Q&A
extra faction tuple in sound entries at WFAS, Somebody, Modding Q&A
soiund for different kinds of horses, MadVader, Modding Q&A
2D determines just plays stereo with left and right determining volume in each channel, without falloff from distance. 3D determines the volume by distance from listener, with the left and right channels being determined by listener facing. Native obviously supports 3D audio. (dstn)
Silencing horses, Lumos, Modding Q&A
limit of sounds to a weapon, kalarhan, Modding Q&A
32 samples per sound, _Sebastian_, Modding Q&A
sounds at distance, _Sebastian_, Modding Q&A
sound priority, _Sebasitan_, Modding Q&A
bullet sounds, kalarhan, Modding Q&A and Modding Q&A
Speed of sound simulation script, _Sebastian_, Modding Q&A
Sound modification, Colt, Sound Modification Guide